package GUI;

import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.Toolkit;
import java.awt.SystemColor;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.border.LineBorder;

public class Splash extends JFrame implements ActionListener{


 
	private static final long serialVersionUID = 1L;

public Splash() {
    
     this.setSize(280, 230);
     
    setEnabled(false);
  	setAlwaysOnTop(true);
  	this.setUndecorated(true);
  	this.setSize(280, 230);
  	
  	Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
  	
  	int w = this.getSize().width;
     int h = this.getSize().height;
     int x = (dim.width-w)/2;
     int y = (dim.height-h)/2;

     // Move the window
     this.setLocation(x, y);
  	
 	setIconImage(Toolkit.getDefaultToolkit().getImage(Splash.class.getResource("/GUI/Image/12_hardware_dock.png")));
  	getContentPane().setLayout(new GridLayout(0, 1, 0, 0));
  	
  	JPanel panel = new JPanel();
  	panel.setBorder(new LineBorder(new Color(0, 0, 0), 2, true));
  	panel.setBackground(SystemColor.activeCaption);
  	getContentPane().add(panel);
  	panel.setLayout(null);
  	
  	JLabel lblConnectToDatabases = new JLabel("Connect to databases");
  	lblConnectToDatabases.setBounds(83, 85, 131, 14);
  	panel.add(lblConnectToDatabases);
  	
  	JLabel label = new JLabel("");
  	label.setForeground(SystemColor.inactiveCaption);
  	label.setBackground(SystemColor.window);
  	label.setIcon(new ImageIcon(Splash.class.getResource("/GUI/Image/bigrotation2.gif")));
  	label.setBounds(115, 110, 48, 45);
  	panel.add(label);
  	
  	JLabel lblNewLabel = new JLabel("");
  	lblNewLabel.setBounds(0, 0, 280, 32);
  	panel.add(lblNewLabel);
  	lblNewLabel.setIcon(new ImageIcon(Splash.class.getResource("/GUI/Image/logo.png")));
    
     this.addWindowListener(closeWindow);

     setVisible(true);
     toFront();
 }
 
 private void doSomething(){
	 
	 for(int i=0; i<100; i++) {
       
         try {
             Thread.sleep(20);
         }
         catch(InterruptedException e) {
         }
     }
	 
  this.setVisible(false);
 }
 
 
 public void actionPerformed(ActionEvent ae) {
     System.exit(0);
 }
  
 private static WindowListener closeWindow = new WindowAdapter(){
  
	 public void windowClosing(WindowEvent e){
         e.getWindow().dispose();
     }
 };
  
 public static void main (String args[]) {
     Splash sp = new Splash();
     sp.doSomething();
     LoginScreen ls = new LoginScreen();
     ls.setVisible(true);
     
 }
 
}
	       
